package com.yang.web;

import java.io.IOException;
import java.sql.SQLException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.yang.service.VersionService;

@Controller
@RequestMapping("/version")
public class VersionController{

	@Resource(name="VersionServiceImpl")
	private VersionService service;
	
	@RequestMapping("/latestVer")
	public void selectLatestVersion(HttpServletRequest request, HttpServletResponse response,
			@RequestParam("companyId") String companyId){
		
		String version = null;
		try {
			version = service.selectLatestVersion(companyId);
			JSONObject jsonObj = new JSONObject();
			jsonObj.put("version", version);
			response.getWriter().write(jsonObj.toString());
		} catch (SQLException e) {
			
			e.printStackTrace();
		} catch (IOException e) {
			
			e.printStackTrace();
		}
	}
}
